﻿namespace dogd
{
	using System.Data.Common;

	/// <summary>
	/// Extension methods for DbConnection class.
	/// </summary>
	public static class DbConnectionExtensions
	{
		/// <summary>
		/// Create a DbCommand using a sql string and a transaction object.
		/// </summary>
		/// <param name="connection">The extended object.</param>
		/// <param name="sql">Raw Sql text.</param>
		/// <param name="transaction">The current transaction.</param>
		/// <returns>An initialized DbCommand object.</returns>
		public static DbCommand CreateCommand(this DbConnection connection, string sql, DbTransaction transaction)
		{
			DbCommand command = connection.CreateCommand();
			command.CommandText = sql;
			command.Transaction = transaction;

			return command;
		}
	}
}
